home *** CD-ROM | disk | FTP | other *** search
/ Mac Power 1997 December / MACPOWER-1997-12.ISO.7z / MACPOWER-1997-12.ISO / AMUG / PROGRAMMING / Raven 1.2 Examples.sit / Raven 1.2 Examples / Quill / Source / BasePaneEditor.h < prev    next >
Text File  |  1997-07-28  |  4KB  |  156 lines

  1. /*
  2.  *  File:       BasePaneEditor.h
  3.  *  Summary:       Abstract base class for view's that edit pane objects.
  4.  *  Written by: Jesse Jones
  5.  *
  6.  *  Copyright ゥ 1996 Jesse Jones. 
  7.  *    For conditions of distribution and use, see copyright notice in ZTypes.h  
  8.  *
  9.  *  Change History (most recent first):    
  10.  *
  11.  *         <->    10/15/96    JDJ        Created
  12.  */
  13.  
  14. #pragma once
  15.  
  16. #include <ZUndoableCommand.h>
  17. #include <ZView.h>
  18.  
  19.  
  20. //-----------------------------------
  21. //    Forward References
  22. //
  23. class TMultipleUndoableCommand;
  24.  
  25.  
  26. // ===================================================================================
  27. //    class CBaseEditPaneCommand
  28. // ===================================================================================
  29. template <class PANE, class PANEINFO>
  30. class CBaseEditPaneCommand : public TUndoableCommand {
  31.  
  32.     typedef TUndoableCommand Inherited;
  33.  
  34. //-----------------------------------
  35. //    Initialization/Destruction
  36. //
  37. public:
  38.     virtual             ~CBaseEditPaneCommand();
  39.     
  40.                         CBaseEditPaneCommand(PANE* pane, const PANEINFO& oldInfo, const PANEINFO& newInfo);
  41.     
  42. //-----------------------------------
  43. //    New API
  44. //
  45. public:
  46.     virtual    void         UpdatePane(const PANEINFO& info) = 0;
  47.  
  48. //-----------------------------------
  49. //    Inherited API
  50. //
  51. public:
  52.     virtual string        GetText() const;
  53.  
  54.     virtual bool         IsValid() const;
  55.  
  56. protected:
  57.     virtual void         OnDo();
  58.  
  59.     virtual void         OnUndo();
  60.  
  61.     virtual void         OnRedo();
  62.             
  63. //-----------------------------------
  64. //    Member data
  65. //
  66. protected:
  67.     TSafePtr<PANE>    mPane;
  68.     PANEINFO        mOldInfo;
  69.     PANEINFO        mNewInfo;
  70. };
  71.  
  72.  
  73. // ===================================================================================
  74. //    CRootPaneEditor
  75. // ===================================================================================
  76. class CRootPaneEditor : public TView {
  77.  
  78.     typedef TView Inherited;
  79.  
  80. //-----------------------------------
  81. //    Initialization/Destruction
  82. //
  83. public:
  84.     virtual                ~CRootPaneEditor();
  85.                         
  86.                         CRootPaneEditor(TView* superView);
  87.  
  88. //-----------------------------------
  89. //    New API
  90. //
  91. public:
  92.     virtual void         SetPane(TPane* pane) = 0;
  93.     
  94.     virtual bool         Validate();
  95.                         // Return false if the data in the editor isn't good to go.
  96.                         
  97.     virtual void         Apply() = 0;
  98.                         // Updates the pane with any changes the user has made.
  99.     
  100.     virtual void         Commit(TMultipleUndoableCommand* command) = 0;
  101.                         // Finalizes any changes the user may have made.
  102.  
  103.     virtual void         Revert() = 0;
  104.                         // Reverts the pane to it's original state.
  105. };
  106.  
  107.  
  108. // ===================================================================================
  109. //    CBasePaneEditor
  110. // ===================================================================================
  111. template <class PANE, class PANEINFO, class EDITCOMMAND>
  112. class CBasePaneEditor : public CRootPaneEditor {
  113.  
  114.     typedef CRootPaneEditor Inherited;
  115.  
  116. //-----------------------------------
  117. //    Initialization/Destruction
  118. //
  119. public:
  120.     virtual                ~CBasePaneEditor();
  121.                         
  122.                         CBasePaneEditor(TView* superView);
  123.  
  124. //-----------------------------------
  125. //    Inherited API
  126. //
  127. public:
  128.     virtual void         SetPane(TPane* pane);
  129.     
  130.     virtual void         Apply();
  131.     
  132.     virtual void         Commit(TMultipleUndoableCommand* command);
  133.  
  134.     virtual void         Revert();
  135.  
  136. //-----------------------------------
  137. //    Internal API
  138. //
  139. protected:    
  140.     virtual PANEINFO     GetEditorInfo() const = 0;
  141.             
  142.     virtual void         SetEditorInfo(const PANEINFO& info) = 0;
  143.             
  144.             void         SetPaneInfo(const PANEINFO& info);
  145.             
  146. //-----------------------------------
  147. //    Member data
  148. //
  149. protected:
  150.     PANE*        mPane;
  151.     PANEINFO    mOldInfo;
  152. };
  153.  
  154.  
  155. #include "BasePaneEditor.inc"
  156.